package com.changyou.kf.core.exception;

/**
 * 远程调用异常错误
 */
public class RpcException extends RuntimeException {

    protected int code = 1;

    protected String msg = "OK";

    public RpcException(int code, String msg) {
        super(formatMsg(code, msg));
        this.code = code;
        this.msg = msg;
    }

    public RpcException(int code, String msg, Throwable cause) {
        super(formatMsg(code, msg), cause);
        this.code = code;
        this.msg = msg;
    }

    public int getCode() {
        return this.code;
    }

    public String getMsg() {
        return msg;
    }

    public final static String formatMsg(int code, String msg) {
        return String.format("%d-%s", code, msg);
    }
}
